package com.dingyx.ps.task;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.UUID;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@Service
public class PSSKUListService extends PostStationRequest{

    private String serviceName = "list.sku";

    private String version = "v1.1";
    Map<String, Object> params = new HashMap<>();

    /**
     * 获取点位
     */
    public void openApiMethod(){
        params.put("service", serviceName);
        String body = super.openApiMethod(params);
        JSONObject jo = JSONObject.parseObject(body);
        if("SUCCESS".equalsIgnoreCase(jo.getString("return_code"))){
            JSONArray skuList = jo.getJSONArray("sku_list");
            if(CollectionUtil.isEmpty(skuList)){
                return;
            }

        }
    }
    public void openApiMethod(String vmCode){
        params.put("vm_id", vmCode);
        params.put("version", version);
        params.put("random_code", UUID.randomUUID().toString());
        openApiMethod();
    }
}
